#include "ChunkyTriMesh.h"
#ifdef __cplusplus
extern "C" {
#endif
void nav_rcChunkyTriMesh_Delete(rcChunkyTriMesh * c_this){
	if(c_this==0){
	    return;
	}
	delete c_this;
}

void nav_rcChunkyTriMesh_DeleteArray(rcChunkyTriMesh * c_this){
	if(c_this==0){
		return;
	}
	delete []c_this;
}

int * nav_rcChunkyTriMesh_GetPtrToMaxTrisPerChunk(rcChunkyTriMesh * c_this){
	return (int *)(&(c_this->maxTrisPerChunk));
}

int * nav_rcChunkyTriMesh_GetPtrToNnodes(rcChunkyTriMesh * c_this){
	return (int *)(&(c_this->nnodes));
}

rcChunkyTriMeshNode * * nav_rcChunkyTriMesh_GetPtrToNodes(rcChunkyTriMesh * c_this){
	return (rcChunkyTriMeshNode * *)(&(c_this->nodes));
}

int * nav_rcChunkyTriMesh_GetPtrToNtris(rcChunkyTriMesh * c_this){
	return (int *)(&(c_this->ntris));
}

int * * nav_rcChunkyTriMesh_GetPtrToTris(rcChunkyTriMesh * c_this){
	return (int * *)(&(c_this->tris));
}

rcChunkyTriMesh * nav_rcChunkyTriMesh_IndexArray(rcChunkyTriMesh * c_this,long n){
	if(c_this==0){
		return 0;
	}
	c_this+=n;
	return c_this;
}

rcChunkyTriMesh * nav_NewrcChunkyTriMesh(){
	rcChunkyTriMesh* wrap_out = new rcChunkyTriMesh();
	return wrap_out;
}

void nav_rcChunkyTriMeshNode_Delete(rcChunkyTriMeshNode * c_this){
	if(c_this==0){
	    return;
	}
	delete c_this;
}

void nav_rcChunkyTriMeshNode_DeleteArray(rcChunkyTriMeshNode * c_this){
	if(c_this==0){
		return;
	}
	delete []c_this;
}

float(*nav_rcChunkyTriMeshNode_GetPtrToBmax(rcChunkyTriMeshNode * c_this))[2]{
	return (float(*)[2])(&(c_this->bmax));
}

float(*nav_rcChunkyTriMeshNode_GetPtrToBmin(rcChunkyTriMeshNode * c_this))[2]{
	return (float(*)[2])(&(c_this->bmin));
}

int * nav_rcChunkyTriMeshNode_GetPtrToI(rcChunkyTriMeshNode * c_this){
	return (int *)(&(c_this->i));
}

int * nav_rcChunkyTriMeshNode_GetPtrToN(rcChunkyTriMeshNode * c_this){
	return (int *)(&(c_this->n));
}

rcChunkyTriMeshNode * nav_rcChunkyTriMeshNode_IndexArray(rcChunkyTriMeshNode * c_this,long n){
	if(c_this==0){
		return 0;
	}
	c_this+=n;
	return c_this;
}

rcChunkyTriMeshNode * nav_NewrcChunkyTriMeshNode(){
	rcChunkyTriMeshNode* wrap_out = new rcChunkyTriMeshNode();
	return wrap_out;
}

rcChunkyTriMeshNode * nav_NewRcChunkyTriMeshNodePtrArray(long n){
	rcChunkyTriMeshNode* c_this=new rcChunkyTriMeshNode[n];
	return c_this;
}

rcChunkyTriMesh * nav_NewRcChunkyTriMeshPtrArray(long n){
	rcChunkyTriMesh* c_this=new rcChunkyTriMesh[n];
	return c_this;
}

bool nav_rcCreateChunkyTriMesh(float const * verts,int const * tris,int ntris,int trisPerChunk,rcChunkyTriMesh * cm){
	float const * c_arg_verts=(float const *)(void*)(verts);
	int const * c_arg_tris=(int const *)(void*)(tris);
	int c_arg_ntris=ntris;
	int c_arg_trisPerChunk=trisPerChunk;
	rcChunkyTriMesh * c_arg_cm=(rcChunkyTriMesh *)(void*)(cm);
	bool c_out = rcCreateChunkyTriMesh(c_arg_verts,c_arg_tris,c_arg_ntris,c_arg_trisPerChunk,c_arg_cm);
	bool wrap_out  = (c_out);
	return wrap_out;
}

int nav_rcGetChunksOverlappingRect(rcChunkyTriMesh const * cm,float(*bmin)[2],float(*bmax)[2],int * ids,int const maxIds){
	rcChunkyTriMesh const * c_arg_cm=(rcChunkyTriMesh const *)(void*)(cm);
	float(&c_arg_bmin)[2]=*(float(*)[2])(void*)(bmin);
	float(&c_arg_bmax)[2]=*(float(*)[2])(void*)(bmax);
	int * c_arg_ids=(int *)(void*)(ids);
	int const c_arg_maxIds=maxIds;
	int c_out = rcGetChunksOverlappingRect(c_arg_cm,c_arg_bmin,c_arg_bmax,c_arg_ids,c_arg_maxIds);
	int wrap_out  = (c_out);
	return wrap_out;
}

int nav_rcGetChunksOverlappingSegment(rcChunkyTriMesh const * cm,float(*tmp_arg_p)[2],float(*q)[2],int * ids,int const maxIds){
	rcChunkyTriMesh const * c_arg_cm=(rcChunkyTriMesh const *)(void*)(cm);
	float(&c_arg_tmp_arg_p)[2]=*(float(*)[2])(void*)(tmp_arg_p);
	float(&c_arg_q)[2]=*(float(*)[2])(void*)(q);
	int * c_arg_ids=(int *)(void*)(ids);
	int const c_arg_maxIds=maxIds;
	int c_out = rcGetChunksOverlappingSegment(c_arg_cm,c_arg_tmp_arg_p,c_arg_q,c_arg_ids,c_arg_maxIds);
	int wrap_out  = (c_out);
	return wrap_out;
}

#ifdef __cplusplus
}
#endif
